package liangtWorkSpace.validation.expetion;

import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName MyController
 * @Description : 功能说明
 * @Author : LiangT
 * @Date : 2020/4/24 17:14
 */
@RestController
public class MyController {
    @RequestMapping("/home")
    public String home(ModelMap modelMap) {
        System.out.println(modelMap.get("author"));
        return "home";
    }

//或者 通过@ModelAttribute获取

    @RequestMapping("/homeMode1")
    public String homeMode1(@ModelAttribute("author") String author) {
        System.out.println(author);
        return "homeMode1";
    }

    @RequestMapping("/homeMyExpetion")
    public String homeMyExpetion() {
        throw new MyException("100001","Sam错误");
    }
}
